function count_same_elements(collection) {
  //在这里写入代码
  var obj = {}
  for (let item of collection) {
    if (obj[item]) {
      obj[item]++;
    } else {
      obj[item] = 1;
    }
  }
  var result = []
  for (let key in obj) {
    let temp = {}
    temp.key = key;
    temp.count = obj[key];
    result.push(temp)
  }
  return result;
}

module.exports = count_same_elements;
